package sql_wc;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RedTest extends Reducer<Text, IntWritable, SendTable, NullWritable> {
    SendTable k = new SendTable();
    int count = 0;

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        for (IntWritable v : values) {
            count++;
        }
        k.set(key.toString(), count);
        System.out.println(k.getWord()+":"+k.getCount());
        context.write(k, NullWritable.get());
        count=0;
    }
}
